//封装一个办法，参数为时间，输出刚刚，几分钟前，几小时前
function dateFormat(date) {
  var nowDate = new Date().getTime()
  // nowDate = nowDate.getTime()
  var oldDate = new Date(date).getTime()
  var diff = (nowDate - oldDate) / 1000
  var str = '秒前'
  if (diff < 60) {
    return '刚刚'
  } else {
    diff = parseInt(diff / 60)
    str = '分钟前'
    if (diff >= 60) {
      diff = parseInt(diff / 60)
      str = '小时前'
      if (diff >= 24) {
        diff = parseInt(diff / 24)
        str = '天前'
      }
    }
  }
  return diff + str
}
//现在是什么浏览器内核
function bowser() {
  var a = navigator.userAgent
  return {
    trident: a.indexOf('Trident') > -1, //IE内核
    presto: a.indexOf('Presto') > -1, //opera内核
    webKit: a.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
    gecko: a.indexOf('Firefox') > -1, //火狐内核Gecko
  }
}
//现在是PC还是移动端
function isMobile() {
  if (window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) {
    return '移动端'; // 移动端
  } else {
    return 'PC端'; // PC端
  }
}
//判断是否是微信浏览器
//判断是否微信登陆
function isWeiXin() {
  var ua = window.navigator.userAgent.toLowerCase();
  //console.log(ua);//mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1
  if (ua.match(/MicroMessenger/i) == 'micromessenger') {
    return true;
  } else {
    return false;
  }
}
/**
 *
 * @param {String} key
 * @return  String
 */
function getParams(key) {
  let query = window.location.search.substring(1)
  query = decodeURI(query)
  let arr = query.split('&')
  for (let i = 0; i < arr.length; i++) {
    var tempArr = arr[i].split('=')
    if (tempArr[0] == key) {
      return tempArr[1]
    }
  }
}